package StudentManager;

import java.util.Scanner;

public class StudentManager {
/**
 @Auther: 86176
 @Date: 2021/4/24 - 04 - 24 - 14:57
 @Description: StudentManager
 @version: 1.0
 */
    Student[] students = new Student[3];

    public void inputStudent(){
        Scanner scanner = new Scanner(System.in);



        for (int i = 0; i < students.length; i++) {
            Student st = new Student();
            System.out.println("请输入你的姓名：");
            String name = scanner.next();
            System.out.println("请输入你的班级：");
            String className = scanner.next();
            System.out.println("请输入你的年龄：");
            int age = scanner.nextInt();
            System.out.println("请输入你的java成绩：");
            int java = scanner.nextInt();
            System.out.println("请输入你的javaWeb成绩：");
            int javaWeb = scanner.nextInt();
            System.out.println("请输入你的html成绩：");
            int html = scanner.nextInt();

            st.name = name ;
            st.age = age;
            st.className  = className;
            st.java = java;
            st.javaWeb = javaWeb;
            st.html = html;
            st.sum = st.java + st.javaWeb + st.html;

            students[i] = st;
        }
    }

    public void sort(){


        for (int i = 0; i <students.length ; i++) {
            for (int j = i+1; j <students.length ; j++) {
                boolean flag = true;
                if (students[i].sum<students[j].sum){
                    Student st = students[i];
                    students[i] = students[j];
                    students[j] = st;
                    flag = false;
                }
                if (!flag)break;
            }
        }
    }

    public void show(){
        for (Student st : students) {
            System.out.println("姓名：" + st.name + "\t年龄：" + st.age + "\t班级：" + st.className
                    + "\tjava成绩：" + st.java + "\tjavaWeb成绩：" + st.javaWeb + "\thtml成绩：" + st.html + "\t总分：" + st.sum);
        }
    }

    public void run(){
        inputStudent();
        sort();
        show();
    }

}
